package org.chw.netty.client;

import java.io.BufferedWriter;
import java.io.IOException;
import java.io.OutputStream;
import java.io.OutputStreamWriter;
import java.net.Socket;

/**
 * @ClassName: SocketClient
 * @Description: socketClient
 * @Author: Vincent.Chen
 * @Create: 2018/6/11 16:58
 * @Version: 1.0
 **/
public class SocketClient {
    private String host;
    private int port;

    public SocketClient(String host, int port) {
        this.host = host;
        this.port = port;
    }

    private void client() {
        try {
            Socket socket = new Socket("127.0.0.1", 8888);
            while (true) {
                OutputStream ops = socket.getOutputStream();
                BufferedWriter bwr = new BufferedWriter(new OutputStreamWriter(ops));
                bwr.write("什么鬼\n");
                bwr.flush();
            }
            // ops.flush();
            // new OutPutHandler(ops).start();
        } catch (IOException e) {
            e.printStackTrace();
        }
    }

    public void start() {
        client();
    }

}
